using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_UserControls_TopNavigation : System.Web.UI.UserControl
{
    private const string CURRENT_ITEM_CLASS = "Current";
    protected void Page_Load(object sender, EventArgs e)
    {        
        if (!Page.IsPostBack)
        {
            UpdateView();
        }
    }

    public void UpdateView()
    {
        BuildMenu();
        ChooseActiveLink();
    }

    public void BuildMenu()
    {

        this.userManagementLink.InnerHtml = "Users";
        this.userManagementLink.HRef = ResolveUrl(string.Format("~/{0}", SitePages.BO_ListUser));

        this.categoryManagementLink.InnerHtml = "Categories";
        this.categoryManagementLink.HRef = ResolveUrl(string.Format("~/{0}", SitePages.BO_ListCategory));

        this.bookManagementLink.InnerHtml = "Books";
        this.bookManagementLink.HRef = ResolveUrl(string.Format("~/{0}", SitePages.BO_ListBook));

        this.publisherManagementLink.InnerHtml = "Publishers";
        this.publisherManagementLink.HRef = ResolveUrl(string.Format("~/{0}", SitePages.BO_ListPublisher));

        this.publicationManagementLink.InnerHtml = "Publications";
        this.publicationManagementLink.HRef = ResolveUrl(string.Format("~/{0}", SitePages.BO_ListPublication));

        this.languageManagementLink.InnerHtml = "Languages";
        this.languageManagementLink.HRef = ResolveUrl(string.Format("~/{0}", SitePages.BO_ListLanguage));
    }

    public void ChooseActiveLink()
    {
        if (MenuManager.IsUserManagementSection())
        {
            MenuManager.SetActive(this.userManagementItem, CURRENT_ITEM_CLASS);
        }
        else if(MenuManager.IsBookManagementSection())
        {
            MenuManager.SetActive(this.bookManagementItem, CURRENT_ITEM_CLASS);
        }
        else if (MenuManager.IsPublisherManagementSection())
        {
            MenuManager.SetActive(this.publisherManagementItem, CURRENT_ITEM_CLASS);
        }
        else if (MenuManager.IsPublicationManagementSection())
        {
            MenuManager.SetActive(this.publicationManagementItem, CURRENT_ITEM_CLASS);
        }
        else if (MenuManager.IsLanguageManagementSection())
        {
            MenuManager.SetActive(this.languageManagementItem, CURRENT_ITEM_CLASS);
        }
        else if (MenuManager.IsCategoryManagementSection())
        {
            MenuManager.SetActive(this.categoryManagementItem, CURRENT_ITEM_CLASS);
        }
    }
}
